#include <iostream>
using namespace std;

template<class T>
class Extreme{
    //输入数的个数
    int numSize;
    T extremeValue;
    T *nums;
public:
    Extreme(int numSize){
        this->numSize = numSize;
        this->nums=nullptr;
    }
    Extreme(T* nums,int numSize){
        this->numSize = numSize;
        setNums(nums);
    }
    ~Extreme(){
        if(nums != nullptr){
            delete[] nums;
        }
    }
    void setNums(T* nums){
        this->nums = new T[numSize];
        for(int i = 0;i < numSize;i++){
            this->nums[i] = nums[i];
        }
    }
    T getExtremeValue(){
        if(nums == nullptr){
            cout << "error: nums is nullptr" << endl;
            return (T)0;
        }
        extremeValue = nums[0];
        for(int i = 1;i < numSize;i++){
            if(nums[i] < extremeValue){
                extremeValue = nums[i];
            }
        }
        return extremeValue;
    }
};
int main(){
    int n=4;
    cout<<"请输入 "<<n<<" 个整数: "<<endl;
    int *nums = new int[n];
    for(int i=0;i<n;i++){
        cin>>nums[i];
    }
    Extreme<int> ex1 = Extreme<int>(nums,n);
    cout<<"最小值: "<<ex1.getExtremeValue()<<endl;
    delete []nums;

    cout<<"请输入 "<<n<<" 个浮点数: "<<endl;
    double *dnums = new double[n];
    for(int i=0;i<n;i++){
        cin>>dnums[i];
    }
    Extreme<double> ex2 = Extreme<double>(dnums,n);
    cout<<"最小值: "<<ex2.getExtremeValue()<<endl;
    delete []dnums;
    return 0;
}